54575e55caf9a7781d95e0d2e5f41d163eac3ce2,core/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceAggregationBuilder.java,ValuesSourceAggregationBuilder,config,#AggregationContext#,312
Before Change
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType);
config.missing = missing;
config.timeZone = timeZone;
config.format = resolveFormat(format, valueType);
config.unmapped = true;
if (valueType != null) {
// todo do we really need this for unmapped?
After Change
public ValuesSourceConfig<VS> config(AggregationContext context) {
ValueType valueType = this.valueType != null ? this.valueType : targetValueType;
if (field == null) {
if (script == null) {
@SuppressWarnings("unchecked")
ValuesSourceConfig<VS> config = new ValuesSourceConfig(ValuesSourceType.ANY);
config.format(resolveFormat(null, valueType));
return config;
}
ValuesSourceType valuesSourceType = valueType != null ? valueType.getValuesSourceType() : this.valuesSourceType;
if (valuesSourceType == null || valuesSourceType == ValuesSourceType.ANY) {
// the specific value source type is undefined, but for scripts,
// we need to have a specific value source
// type to know how to handle the script values, so we fallback
// on Bytes
valuesSourceType = ValuesSourceType.BYTES;
}
ValuesSourceConfig<VS> config = new ValuesSourceConfig<VS>(valuesSourceType);
config.missing(missing);
config.timezone(timeZone);
config.format(resolveFormat(format, valueType));
config.script(createScript(script, context.searchContext()));
config.scriptValueType(valueType);
return config;
}
MappedFieldType fieldType = context.searchContext().smartNameFieldType(field);
if (fieldType == null) {
ValuesSourceType valuesSourceType = valueType != null ? valueType.getValuesSourceType() : this.valuesSourceType;
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType);
config.missing(missing);
config.timezone(timeZone);
config.format(resolveFormat(format, valueType));
config.unmapped(true);
if (valueType != null) {
// todo do we really need this for unmapped?